package queue

import (
	"fmt"
	"sync"
)

var (
	manager sync.Mutex
	drivers map[string]IQueueDriver
)

func init() {
	drivers = make(map[string]IQueueDriver)
}

func RegisterDriver(name string, driver IQueueDriver) {
	if _, ok := drivers[name]; ok {

	}
	manager.Lock()
	defer manager.Unlock()
	drivers[name] = driver
}

func GetDriver(name string) (driver IQueueDriver) {
	if driver, ok := drivers[name]; ok {
		return driver
	}
	panic(fmt.Sprintf("Queue Driver %s Not Register!", name))
}
